﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace 代理模式
{
    public interface IMath
    {
        double Add(double x, double y);

        double Sub(double x, double y);

        double Mul(double x, double y);

        double Div(double x, double y);

    }

    public class Math : IMath
    {
        public double Add(double x, double y)
        {
            return x + y;
        }

        public double Div(double x, double y)
        {
            return x / y;
        }

        public double Mul(double x, double y)
        {
            return x * y;
        }

        public double Sub(double x, double y)
        {
            return x - y;
        }
    }

    public class MathProxy : IMath
    {
        Math math = new Math();
        public double Add(double x, double y)
        {
            return math.Add(x, y);
        }

        public double Div(double x, double y)
        {
            return math.Div(x, y);
        }

        public double Mul(double x, double y)
        {
            return math.Mul(x, y);
        }

        public double Sub(double x, double y)
        {
            return math.Sub(x, y);
        }
    }


    class Program
    {
        static void Main(string[] args)
        {

            Math mathProxy = new Math();
            var a1 = mathProxy.Add(1, 3);
            var a2 = mathProxy.Div(10, 2);
            var a3 = mathProxy.Mul(10, 2);
            var a4 = mathProxy.Sub(10, 2);

        }
    }
}
